﻿using MediatR;
using SlaughterItem.Common.Domains.Check_Ins;
using SlaughterItem.Common.Dtos;
using SlaughterItem.Common.Infrastructures.Interfaces;
using SlaughterItem.Enum;

namespace SlaughterItem.API.Application.Commands.Week02._IPQC.ShowpigData
{
    public class ShowAddPigHandler : IRequestHandler<ShowpigDataCommand, Result>
    {
        public IBaseRepository<CheckIn> CheckInRepository;

        public ShowAddPigHandler(IBaseRepository<CheckIn> checkInRepository)
        {
            CheckInRepository = checkInRepository;
        }

        public async Task<Result> Handle(ShowpigDataCommand request, CancellationToken cancellationToken)
        {
            var result  = new Result() { Code=(int)CommonErrorCode.Search};
            var list = CheckInRepository.GetAll().ToList();
            result.Data = list;
            return result;
        }
    }
}
